package com.example.ljc;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author yan
 */
@RestController
public class TestController {
    final UserRepository userRepository;
    TestController(UserRepository userRepository){
        this.userRepository = userRepository;
    }

    @GetMapping(value = "/list")
    public List<UserEntity> home(){
        return userRepository.findAll();
    }

    @GetMapping(value = "/save")
    public UserEntity save(){
        UserEntity user = new UserEntity();
        user.setName("hahah");
        return userRepository.save(user);
    }
}
